/*
 * @Descripttion:
 * @version:
 * @Date: 2021-04-20 11:06:21
 * @Author: jekingxu@163.com
 * @LastEditTime: 2022-09-27 14:57:06
 * @Author: jekingxu@163.com
 * @HomePage: https://xuxiaowen.space/vue3-element-admin
 * @Github: https://github.com/xuxiaowengjt
 * 
 */
import { defineStore } from 'pinia'
import { GetUserinfo } from '@/api/login'

export const useAccount = defineStore('account', {
    state: () => ({
        userinfo: null,
        permissionList: [],
    }),
    actions: {
        // 清除用户信息
        clearUserinfo() {
            this.userinfo = null
        },
        // 获取用户信息
        async getUserinfo() {
            const { code, data } = await GetUserinfo()
            if (+code === 200) {
                this.userinfo = data
                return Promise.resolve(data)
            }
        },
    },
})